//
//  AppDelegate.swift
//  GitTFGUI
//
//  Created by Samuel Richard Magny on 2015-08-29.
//  Copyright (c) 2015 Samuel Richard Magny. All rights reserved.
//

import Cocoa
import TFSClient

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var cloneMenuButton: NSMenuItem!
    @IBOutlet weak var checkinMenuButton: NSMenuItem!
    @IBOutlet weak var pullMenuButton: NSMenuItem!
    @IBOutlet weak var commitMenuButton: NSMenuItem!
    
    var tfsClient:ExtendedTFSClient { get{return applicationModel.tfsClient} }
    var userSettings:UserSettings { get{return applicationModel.userSettings} }
    
    let notificationCenter:TFSClientNotificationCenter
    
    let applicationModel:ApplicationModel
    let userNotificationHandler:OSXNotificationHandler
    
    override init() {
        self.applicationModel = ApplicationModel.DefaultApplicationModel
        self.notificationCenter = applicationModel.notificationCenter
        self.userNotificationHandler = OSXNotificationHandler(notificationCenter: notificationCenter)
    }
    
    func applicationDidFinishLaunching(aNotification: NSNotification) {

        let workingDir = tfsClient.workingDirectory
        tfsClient.workingDirectory = workingDir
    }

    func applicationWillTerminate(aNotification: NSNotification) {
        // Insert code here to tear down your application
    }
    
    func applicationShouldTerminateAfterLastWindowClosed(sender: NSApplication) -> Bool {
        return true
    }
}

